refspec = argv[1];
- if (!ot_admin_sysroot_lock (sysroot, error))
- goto out;
-
if (!ostree_sysroot_load (sysroot, cancellable, error))
goto out;
ret = TRUE;
out:
- if (sysroot)
- ostree_sysroot_unlock (sysroot);
if (origin)
g_key_file_unref (origin);
if (context)
g_option_context_add_main_entries (context, options, NULL);
if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
- OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER,
+ OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER | OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED,
&sysroot, cancellable, error))
goto out;
context = g_option_context_new ("PATH - Initialize a root filesystem");
if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
- OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER,
+ OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER | OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED,
&sysroot, cancellable, error))
goto out;
/* This will not return for some options (e.g. --version). */
if (ostree_admin_option_context_parse (context, NULL, &argc, &argv,
- OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER,
+ OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER | OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED,
NULL, cancellable, error))
{
if (subcommand_name == NULL)
context = g_option_context_new ("OSNAME - Initialize empty state for given operating system");
if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
- OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER,
+ OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER | OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED,
&sysroot, cancellable, error))
goto out;
#include <string.h>
#include "ostree.h"
+#include "ot-admin-functions.h"
#include "ot-main.h"
#include "otutil.h"
exit (EXIT_SUCCESS);
}
+ if ((flags & OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED) == 0)
+ {
+ /* Released when sysroot is finalized, or on process exit */
+ if (!ot_admin_sysroot_lock (sysroot, error))
+ goto out;
+ }
+
gs_transfer_out_value (out_sysroot, &sysroot);
success = TRUE;
typedef enum {
OSTREE_ADMIN_BUILTIN_FLAG_NONE = 0,
- OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER = 1 << 0
+ OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER = 1 << 0,
+ OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED = 1 << 1
} OstreeAdminBuiltinFlags;
typedef struct {